<?php

namespace App\Http\Controllers\Front;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class Form extends Controller
{
    use \App\Traits\FormTrait;
    public function index(Request $request)
    {
        $type = $request->input('form_type');
        //var_dump($request->all());exit;
        switch ($type) {
            case 'tech_device':
                $this->techDeviceFormCreate($request);
                break;
            case 'worker':
                $this->workerFormCreate($request);
                break;
            case 'boater':
                $this->boaterFormCreate($request);
                break;
            default:
                # code...
                break;
        }
    }

    public function techDeviceFormCreate($request)
    {
        $data = $this->techDeviceFormData($request);
        echo $data ? json_encode(['result' => 0]) : json_encode(['result' => -1, 'msg' => '提交错误，请稍候重试']);
    }

    public function workerFormCreate($request)
    {
        $data = $this->workerFormData($request);
        echo $data ? json_encode(['result' => 0]) : json_encode(['result' => -1, 'msg' => '提交错误，请稍候重试']);
    }

    public function boaterFormCreate($request)
    {
        $data = $this->boaterFormData($request);
        echo $data ? json_encode(['result' => 0]) : json_encode(['result' => -1, 'msg' => '提交错误，请稍候重试']);
    }
}
